package net.anumbrella.seaweedfs.core.topology;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@NoArgsConstructor
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class WeedEntity {

    @JsonProperty("Topology")
    private TopologyDTO topology;
    @JsonProperty("Version")
    private String version;

    @NoArgsConstructor
    @Data
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class TopologyDTO {
        @JsonProperty("DataCenters")
        private List<DataCentersDTO> dataCenters;
        @JsonProperty("Free")
        private Integer free;
        @JsonProperty("Layouts")
        private List<LayoutsDTO> layouts;
        @JsonProperty("Max")
        private Integer max;

        @NoArgsConstructor
        @Data
        @JsonIgnoreProperties(ignoreUnknown = true)
        public static class DataCentersDTO {
            @JsonProperty("Id")
            private String id;
            @JsonProperty("Racks")
            private List<RacksDTO> racks;

            @NoArgsConstructor
            @Data
            @JsonIgnoreProperties(ignoreUnknown = true)
            public static class RacksDTO {
                @JsonProperty("DataNodes")
                private List<DataNodesDTO> dataNodes;
                @JsonProperty("Id")
                private String id;

                @NoArgsConstructor
                @Data
                @JsonIgnoreProperties(ignoreUnknown = true)
                public static class DataNodesDTO {
                    @JsonProperty("EcShards")
                    private Integer ecShards;
                    @JsonProperty("Max")
                    private Integer max;
                    @JsonProperty("PublicUrl")
                    private String publicUrl;
                    @JsonProperty("Url")
                    private String url;
                    @JsonProperty("VolumeIds")
                    private String volumeIds;
                    @JsonProperty("Volumes")
                    private Integer volumes;
                }
            }
        }

        @NoArgsConstructor
        @Data
        @JsonIgnoreProperties(ignoreUnknown = true)
        public static class LayoutsDTO {
            @JsonProperty("collection")
            private String collection;
            @JsonProperty("replication")
            private String replication;
            @JsonProperty("ttl")
            private String ttl;
            @JsonProperty("writables")
            private List<Integer> writables;
        }
    }
}
